<%@page import="java.util.Iterator"%>
<%@page import="com.ignou.mca.beans.QuestionsBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.Array"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="theme/style.css"
	media="screen" />
<title>OES - Updating the question</title>
<script type="text/javascript">
function check() 
{
	var question,options,correctAnswer,marks;
	question = document.fm.question.value;
	options = document.fm.options.value;
	correctAnswer = document.fm.correctAnswer.value;
	marks = document.fm.marks.value;
	
	if (question.length < 1) 
	{
		alert("You must enter question");
		document.fm.question.focus();
		return false;
	} 
	else if (options.length < 1) 
	{
		alert("You must enter options");
		document.fm.options.focus();
		return false;
	}
	else if (correctAnswer.length < 1) 
	{
		alert("You must enter correct answer.");
		document.fm.correctAnswer.focus();
		return false;
	}
	else if (marks.length < 1) 
	{
		alert("You must enter marks for this question");
		document.fm.marks.focus();
		return false;
	}
	return true;
}
</script>
</head>
<body onload="userfocus()">
	<div id="MainWrapper">
		<jsp:include page="header.jsp" /> 
		<jsp:include page="LeftContainer.jsp" />
		<div id="MainContent">
		<center>

		<%
			String ques = request.getParameter("question");
			int questionID = Integer.parseInt(ques);
			ArrayList<QuestionsBean> questions = (ArrayList<QuestionsBean>) session.getAttribute("Ques");
		%>
		<form action='Questions.do' method="post" name="fm">
			<input type="hidden" name="questionId" value="<%=questionID%>"/>
			<input type="hidden" name="subjectId" value="0"/>
			<input type="hidden" name="questionType" value="multiple"/>
			<input type="hidden" name="CMD" value="update"/>
			<table>
				<thead><b>Update Question</b></thead><br>
			<%
			if(questions.size()>0)
			{
				for(int i=0;i<questions.size();i++)
				{
					QuestionsBean qb = questions.get(i);
					String s = "";
					if(qb.getQuestionId()==questionID)
					{
						for(int ii=0;ii<qb.getOptions().size();ii++)
						{
							if(ii==qb.getOptions().size()-1)
							{
								s = s+ qb.getOptions().get(ii);
							}else
							{
								s = s+ qb.getOptions().get(ii)+"|";
							}
						}
			%>
			
				<tr><td>Question:</td><td><input type="text" name="question" value='<%=qb.getQuestion()%>'/></td></tr>
				<tr><td>Options:</td><td><input type="text" name="options"  value='<%=s%>'/>
				<br>(Enter all options separated by "|".)</td></tr>
				<tr><td>Correct Answer:</td><td><input type="text" name="correctAnswer"  value='<%=qb.getCorrectAnswer()%>'/></td></tr>
				<tr><td>Marks:</td><td><input type="text" name="marks" value='<%=qb.getMarks()%>'/></td></tr>
				<tr><td></td><td><input type="submit" name="submit" value="Submit"/>
				<input type="reset" value="Reset"></td></tr>
			
			<%
					}
				}
			}
			%>
		</table>
		</form>
		</center>
			
		</div>
		<jsp:include page="footer.jsp" />
	</div>
</body>
</html>